package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 加班申请
 * </p>
 *
 * @author dq
 * @date 2022-10-19
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOvertimeWorkOvertimeSourceEnum", description = "加班申请来源 #{ONLINE_BOOK:线上预定;ON_SITE_ORDER:现场预定-枚举")
public enum WorkOvertimeWorkOvertimeSourceEnum implements BaseEnum {

    /**
     * ONLINE_BOOK="线上预定"
     */
    ONLINE_BOOK("线上预定"),
    /**
     * ON_SITE_ORDER="现场预定"
     */
    ON_SITE_ORDER("现场预定"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOvertimeWorkOvertimeSourceEnum match(String val, WorkOvertimeWorkOvertimeSourceEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOvertimeWorkOvertimeSourceEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOvertimeWorkOvertimeSourceEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "ONLINE_BOOK,ON_SITE_ORDER", example = "ONLINE_BOOK")
    public String getCode() {
        return this.name();
    }

}
